﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
IF  Request.QueryString("Action")="save" Then
	call savea
else
	call index
end if
end Function



Function index
	dim fleg
    		fleg = Request("fleg")    
    		If fleg = "" Then fleg = 0
   		If Not IsNumeric(fleg) Then fleg = 0
    		fleg = CLng(fleg)
    		If fleg < 0 Then fleg = 0

dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

if len(Request.QueryString("Action"))=0 then

%>
	<card title="添加栏目"><p align="left">
	<a href='addclass.asp?Action=0&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加主栏目</a><br/>
	<a href='addclass.asp?Action=3&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加标签栏目</a><br/>
	<a href='addclass.asp?Action=4&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>直接添加图片</a><br/>
	<a href='addclass.asp?Action=5&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>直接添加文章</a><br/>
	<a href='addclass.asp?Action=6&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加文件栏目</a><br/>
	<a href='addclass.asp?Action=7&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加文章栏目</a><br/>
	<a href='addclass.asp?Action=1&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加商品分类栏目</a><br/>
	<a href='addclass.asp?Action=2&amp;fleg=<%=fleg%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>添加商品品牌栏目</a><br/>
<%
else
if Request.QueryString("Action")<9 then
	add
end if
end if
%>
-------------<br/>
<a href='addclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回添加栏目</a><br/>
<a href='lclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回栏目管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%

End Function




Function add
	dim rs,sql,Runtxt,str,actt,i
	Runtxt=qingtian.RunStr
	dim fleg,pid
        actt=Request.QueryString("Action")
    		fleg = Request("fleg")    
    		If fleg = "" Then fleg = 0
   		If Not IsNumeric(fleg) Then fleg = 0
    		fleg = CLng(fleg)
    		If fleg < 0 Then fleg = 0
dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

			set rs=server.CreateObject("adodb.recordset")
			sql="select top 1 pid from qingtian_class where fleg="&fleg&"  order by [pid] desc"
			rs.open sql,conn,1,1
			if not (rs.bof and rs.eof) then
				pid=rs("pid")+1
			else
				pid=1
			end if
			Rs.close
			set rs=nothing

	select case Request.QueryString("Action")
	case "0"
		str="主"
	case "1"
		str="商品分类"
	case "2"
		str="商品品牌"
	case "3"
		str="标签"
	case "4"
		str="图片"
	case "5"
		str="文章"
	case "6"
		str="文件分类"
	case "7"
		str="文章分类"
	case "8"
		str="图片分类"
	end select

%>
	<card title="添加<%=str%>栏目"><p align="left">
	栏目名称：<%if Request.QueryString("Action")=3 then%>(后台显示)<%end if%><br/>
	<input emptyok="true"  name="name<%=Runtxt%>" maxlength="50" value="" type="text"/><br/>
	<%if Request.QueryString("Action")="1" then%>
         选择<%=str%>：<br/>
<%
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "SELECT * from qingtian_shfeid"
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to  rs.RecordCount
		If Rs.Eof Then
			exit For
		End If
		if i=1 then
		%>
		<select name="urls<%=Runtxt%>" value="/shop/fileli.asp?listid=<%=rs("id")%>&amp;sid=[sid]">
		<%
		end if
		%>
		<option value="/shop/fileli.asp?listid=<%=rs("id")%>&amp;sid=[sid]"><%=qingtian.utf8(rs("name"))%></option>
		<%
	  Rs.MoveNext
	  Next
	else	
	%>
	<select name="urls<%=Runtxt%>" value="">
	<%
	  end if
	  Rs.close
	  set rs=nothing
          actt=2
	%>
	</select><br/>
	<%end if%>
	<%if Request.QueryString("Action")="2" then%>
         选择<%=str%>：<br/>
<%
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "SELECT * from qingtian_shpaid"
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to  rs.RecordCount
		If Rs.Eof Then
			exit For
		End If
		if i=1 then
		%>
		<select name="urls<%=Runtxt%>" value="/shop/paid.asp?id=<%=rs("id")%>&amp;sid=[sid]">
		<%
		end if
		%>
		<option value="/shop/paid.asp?id=<%=rs("id")%>&amp;sid=[sid]"><%=qingtian.utf8(rs("name"))%></option>
		<%
	  Rs.MoveNext
	  Next
	else	
	%>
	<select name="urls<%=Runtxt%>" value="">
	<%
	  end if
	  Rs.close
	  set rs=nothing
	%>
	</select><br/>
	<%end if%>
	<%if Request.QueryString("Action")="6" then%>
         选择<%=str%>：<br/>
<%
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "SELECT * from qingtian_phonefen"
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to  rs.RecordCount
		If Rs.Eof Then
			exit For
		End If
		if i=1 then
		%>
		<select name="urls<%=Runtxt%>" value="/liebie.asp?listid=<%=rs("id")%>&amp;sid=[sid]">
		<%
		end if
		%>
		<option value="/liebie.asp?listid=<%=rs("id")%>&amp;sid=[sid]"><%=qingtian.utf8(rs("name"))%></option>
		<%
	  Rs.MoveNext
	  Next
	else	
	%>
	<select name="urls<%=Runtxt%>" value="">
	<%
	  end if
	  Rs.close
	  set rs=nothing
          actt=2
	%>
	</select><br/>
	<%end if%>
	栏目排序：<br/>
	<input emptyok="true"  name="px<%=Runtxt%>" format="*N" value="<%=pid%>" type="text"/><br/>
	<%if  Request.QueryString("Action")="4" then%>
	图片地址：<a href='wenjian.asp?url=addclass.asp?Action=4@fleg=<%=fleg%>@page=<%=page%>&amp;sid=<%=sid%>'>上传</a><br/>
	<input emptyok="true"  name="img<%=Runtxt%>" maxlength="255"  value="<%=Request.QueryString("tp")%>" type="text"/><br/>
	<%end if%>
	<%if Request.QueryString("Action")="4" then%>
	联接地址(可留空)：<br/>
	<input emptyok="true"  name="urls<%=Runtxt%>" maxlength="255"  value="" type="text"/><br/>
	<%end if%>
	<%if Request.QueryString("Action")="3" or Request.QueryString("Action")="5" then%>
	<%=str%>内容：<br/>
	<input emptyok="true"  name="title<%=Runtxt%>"  value="" type="text"/><br/>
	<%end if%>
	栏目换行:<br/>
	<select name="br<%=Runtxt%>" value="1">
	<option value="1">栏目后自动换行</option>
	<option value="0">栏目后不换行</option>
	</select><br/>
	<%if Request.QueryString("Action")=0 or Request.QueryString("Action")=7 or Request.QueryString("Action")=8 then%>
	金币购买：
   	<select name="vip<%=Runtxt%>" value="0">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	购买金币：<br/>
	<input emptyok="true"  name="zf<%=Runtxt%>"  value="0" type="text"/><br/>
	VIP会员查看：
   	<select name="viphy<%=Runtxt%>" value="0">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	<%end if%>
	隐藏：
   	<select name="yinz<%=Runtxt%>" value="0">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	<anchor>确定提交
    	<go href="addclass.asp?Action=save&amp;act=<%=actt%>&amp;page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>" method='post'>
        <postfield name="name" value="$(name<%=Runtxt%>)"/>
        <postfield name="px" value="$(px<%=Runtxt%>)"/>
        <postfield name="br" value="$(br<%=Runtxt%>)"/>
        <postfield name="urls" value="$(urls<%=Runtxt%>)"/>
        <postfield name="img" value="$(img<%=Runtxt%>)"/>
        <postfield name="title" value="$(title<%=Runtxt%>)"/>
        <postfield name="viphy" value="$(viphy<%=Runtxt%>)"/>
        <postfield name="vip" value="$(vip<%=Runtxt%>)"/>
        <postfield name="zf" value="$(zf<%=Runtxt%>)"/>
        <postfield name="yinz" value="$(yinz<%=Runtxt%>)"/>
    	</go>
	</anchor><br/>
<%
end Function 


Function savea
	dim fleg,vip,zf,viphy
    		fleg = Request("fleg")    
    		If fleg = "" Then fleg = 0
   		If Not IsNumeric(fleg) Then fleg = 0
    		fleg = CLng(fleg)
    		If fleg < 0 Then fleg = 0

dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

		dim name,br,title,px,urls,img,rs,sql,errs,yinz
		name=Request.form("name")
		px=Request.form("px")
		urls=Request.form("urls")
		img=Request.form("img")
		br=Request.form("br")
		title=Request.form("title")
    	    	vip=Request.form("vip")
	        zf=Request.form("zf")
	        yinz=Request.form("yinz")
 		viphy=TRim(Request.Form("viphy"))


		errs=""
		if name="" then errs=errs & "栏目名称不能为空<br/>"
		if px="" then errs=errs & "栏目排序不能为空<br/>"
		if br="" then errs=errs & "栏目换行不能为空<br/>"
		if Not IsNumeric(px) then errs=errs & "栏目排序必需为数字<br/>"
		if Not IsNumeric(br) then errs=errs & "栏目换行必需为数字<br/>"
		if Request.QueryString("act")="2" and urls="" then errs=errs & "联接地址不能为空<br/>"
		if (Request.QueryString("act")="3" or Request.QueryString("act")="5" )and title="" then errs=errs & "内容不能为空<br/>"
		if Request.QueryString("act")="4" and img="" then errs=errs & "图片地址不能为空<br/>"


		if Request.QueryString("act")=0 or Request.QueryString("act")=7 or Request.QueryString("act")=8 then
			if vip=""  then errs=errs&"VIP不能为空<br/>"
			if not isnumeric(vip) then errs=errs&"VIP必须为数字<br/>"
			if zf=""  then errs=errs&"金币不能为空<br/>"
			if not isnumeric(zf) then errs=errs&"金币必须为数字<br/>"
			if viphy=""  then errs=errs&"VIP会员查看不能为空<br/>"
			if not isnumeric(viphy) then errs=errs&"VIP会员查看必须为数字<br/>"

		end if

	IF len(errs)=0 then


		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select  * FROM qingtian_class"
		rs.open sql,conn,1,3
		rs.addnew
			rs("name")=name
			rs("pid")=px
			rs("fleg")=fleg
			rs("br")=br
			rs("urls")=urls
			rs("img")=img
			rs("ext")=Request.QueryString("act")
			rs("content")=title
			rs("yinz")=yinz
		if Request.QueryString("act")=0 or Request.QueryString("act")=7 or Request.QueryString("act")=8 then
			rs("zf")=zf
			rs("vip")=vip
			rs("viphy")=viphy
		end if

		rs.update()

		rs.Close
		Set rs = Nothing
	%>
<card title="修改栏目"><p align="left">
		添加栏目成功!<br/><%

	else%>

	<card title="修改栏目"><p align="left">
		<%=errs%>
		<a href="addclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>">返回修改</a><br/>
<%	end if
%>
<a href='addclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回添加栏目</a><br/>
<a href='lclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回栏目管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function


%>
